package com.ws.shop.service.impl;

import java.util.Date;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.ws.shop.bean.Page;
import com.ws.shop.dao.TicketDao;
import com.ws.shop.entity.Ticket;
import com.ws.shop.service.TicketService;

@Service(value="ticketService")
public class TicketServiceImpl implements TicketService {

	@Resource(name="ticketDao")
	private TicketDao ticketDao;

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public Page findTicketListPage(int pageno,int pagesize) {
		return ticketDao.findTicketListPage(pageno,pagesize);
	}

	public int chargeCard(String cardsn, String cardpwd, long uid, String name) {
		return ticketDao.chargeCard( cardsn,  cardpwd,  uid,  name);
	}

	@Transactional(rollbackFor=Exception.class)
	public void saveTickets(Map<String, String> ticketInfo, int beat,
			int pointb, Date starttime, Date endtime) {
		ticketDao.saveTickets(ticketInfo, beat, pointb, starttime, endtime);
	}

	@Transactional(propagation=Propagation.NOT_SUPPORTED,readOnly=true)
	public Ticket findTicketById(int id) {
		return ticketDao.findTicketById(id);
	}

	@Transactional(rollbackFor=Exception.class)
	public void updateTicket(Ticket ticket) {
		ticketDao.updateTicket(ticket);
	}
	
}
